package com.project.myxima.utils;

import com.project.myxima.fragments.BaseFragment;
import com.project.myxima.fragments.RecommendFragment;
import com.project.myxima.fragments.SignInFragment;
import com.project.myxima.fragments.SignUpFragment;
import com.project.myxima.fragments.SubscriptionFragment;

import java.util.HashMap;
import java.util.Map;

//todo: not knowing what this class do for
public class LoginFragmentCreator {

    /*public final static int SING_IN_FRAGMENT = 0;
    private final static int SING_UP_FRAGMENT = 1;

    public final static int SIZE_FRAGMENT = 2;

    private static HashMap<Integer,BaseFragment> sFragmentHashMap = new HashMap<>();

    public static BaseFragment getFragment(int index) {
        BaseFragment baseFragment = sFragmentHashMap.get(index);
        //不为空直接获取
        if (baseFragment != null) {
            return baseFragment;
        }
        //为空创建对应的fragment并加入map集合
        switch (index){
            case SING_IN_FRAGMENT:
                baseFragment = new SignInFragment();
                break;
            case SING_UP_FRAGMENT:
                baseFragment = new SignUpFragment();
                break;
        }
        sFragmentHashMap.put(index,baseFragment);
        return baseFragment;
    }*/


    //创建下标
    public final static int SING_IN_FRAGMENT = 0;
    public final static int SING_UP_FRAGMENT = 1;
    //public final static int INDEX_HISTORY = 2;

    public final static int PAGE_COUNT = 2;

    public static Map<Integer,BaseFragment> sCache = new HashMap<>();

    public static BaseFragment getFragment(int index){
        BaseFragment baseFragment = sCache.get(index);
        if(baseFragment != null){
            return baseFragment;
        }

        switch (index){
            case SING_IN_FRAGMENT:
                baseFragment = new SignInFragment();
                break;
            /*case INDEX_HISTORY:
                baseFragment = new HistoryFragment();
                break;*/
            case SING_UP_FRAGMENT:
                baseFragment = new SignUpFragment();
                break;
            default:
        }
        sCache.put(index,baseFragment);
        return baseFragment;

    }
}
